/*
 * Filename:    AuditDispatchDao.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014-11-11
 */
package com.paic.mhis.hcpms.audit.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.paic.mhis.hcpms.audit.dto.AuditCaseDTO;
import com.paic.mhis.hcpms.audit.dto.AuditCodeDictionary;
import com.paic.mhis.hcpms.audit.dto.AuditDispatchParamter;
import com.paic.mhis.hcpms.audit.dto.AuditDispatchProblemDTO;
import com.paic.mhis.hcpms.audit.dto.AuditInsuranceInfoDTO;
import com.paic.mhis.hcpms.audit.dto.AuditMedicalInfoDTO;
import com.paic.mhis.hcpms.audit.dto.AuditProblemsDTO;
import com.paic.mhis.hcpms.audit.dto.AuditUserInfoDTO;
import com.paic.mhis.hcpms.audit.dto.AuditiStaffInfoDTO;
import com.paic.pafa.biz.dao.BaseDAO;

@Component("auditDispatchDao")
public class AuditDispatchDao extends BaseDAO {

	/**
	 * 根据案件编码更新案件对象的状态
	 * 
	 * @param bean
	 */
	public void updateAuditCaseDTO(AuditCaseDTO bean) {
		this._update("dispatch.updateAuditCase", bean);
	}

	/**
	 * 根据角色名称查询该角色下的所有用户信息
	 * 
	 * @param roleName
	 * @return
	 */
	public List<AuditUserInfoDTO> queryAuditUserInfoDTO(String roleName) {

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("roleName", roleName);

		List<AuditUserInfoDTO> list = (List<AuditUserInfoDTO>) this
				._queryForList("dispatch.queryAuditUserInfoDTO", map);

		return list;

	}

	/**
	 * 根据数据字典类型和编码加载对应的数据字典对象
	 * 
	 * @param bean
	 * @return
	 */
	public AuditCodeDictionary queryAuditCodeDictionaryByTypeAndCode(
			AuditCodeDictionary bean) {

		List<AuditCodeDictionary> list = (List<AuditCodeDictionary>) this
				._queryForList("dispatch.queryAuditCodeDictionary", bean);

		if (list != null && list.size() > 0) {
			return list.get(0);
		} else {
			return null;
		}

	}

	/**
	 * 更新事件表的状态
	 * 
	 * @param bean
	 */
	public void updateAuditProblemBean(AuditProblemsDTO bean) {
		this._update("dispatch.updateAuditProblems", bean);
	}

	/**
	 * 根据事件编码加载对应的医疗机构信息
	 * 
	 * @param bean
	 * @return
	 */
	public List<AuditMedicalInfoDTO> queryAuditMedicalInfoDTOByProblemNo(
			AuditDispatchParamter bean) {

		List<AuditMedicalInfoDTO> list = (List<AuditMedicalInfoDTO>) this
				._queryForList("dispatch.queryMedicalDTO", bean);
		return list;
	}

	/**
	 * 根据事件编码加载医护人员
	 * 
	 * @param bean
	 * @return
	 */
	public List<AuditiStaffInfoDTO> queryAuditiStaffInfoDTOByProblemNo(
			AuditDispatchParamter bean) {
		List<AuditiStaffInfoDTO> list = (List<AuditiStaffInfoDTO>) this
				._queryForList("dispatch.queryStaffList", bean);
		return list;
	}

	/**
	 * 根据事件编码加载医务人员信息从临时表中
	 * 
	 * @param bean
	 * @return
	 */
	public List<AuditiStaffInfoDTO> queryStaffListFromTempByProblemNo(
			AuditDispatchParamter bean) {
		List<AuditiStaffInfoDTO> list = (List<AuditiStaffInfoDTO>) this
				._queryForList("dispatch.queryStaffListFromTemp", bean);
		return list;
	}

	/**
	 * 根据事件编码加载参保人信息
	 * 
	 * @param bean
	 * @return
	 */
	public List<AuditInsuranceInfoDTO> queryAuditInsuranceInfoDTOByProblemNo(
			AuditDispatchParamter bean) {
		List<AuditInsuranceInfoDTO> list = (List<AuditInsuranceInfoDTO>) this
				._queryForList("dispatch.queryInsuranceDTO", bean);
		return list;
	}

	/**
	 * 根据事件编码加加载对应的参保人信息从临时表中，只是为了暂存做的处理
	 * 
	 * @param bean
	 * @return
	 */
	public List<AuditInsuranceInfoDTO> queryInsuranceDTOFromTempByProblemNo(
			AuditDispatchParamter bean) {
		List<AuditInsuranceInfoDTO> list = (List<AuditInsuranceInfoDTO>) this
				._queryForList("dispatch.queryInsuranceDTOFromTemp", bean);
		return list;
	}

	/**
	 * 根据事件编码加载事件信息
	 * 
	 * @param bean
	 * @return
	 */
	public AuditDispatchProblemDTO queryAuditProblemsDTOByProblemNo(
			AuditDispatchParamter bean) {
		List<AuditDispatchProblemDTO> list = (List<AuditDispatchProblemDTO>) this
				._queryForList("dispatch.queryDispatchProblemBean", bean);
		if (null != list && list.size() > 0) {
			AuditDispatchProblemDTO dto = list.get(0);
			return dto;
		} else {
			return null;
		}

	}
}
